MAGetResource returns a handle to the resource having the specified type and ID number. This routine reads the resource data into memory if it is not already in memory, unless you have called the Toolbox routine SetResLoad with the argument FALSE.
Warning: The handle returned will be an empty handle if you have called SetResLoad with the argument FALSE.
If MAGetResource does not find the resource, it returns NIL and the Toolbox function ResError returns the result code resNotFound. MAGetResource also returns NIL if the resource is to be read into memory but won't fit; in this case, ResError returns an appropriate operating-system result code.
MAGetResource searches in the file referenced by gCodeRefNum and all resource files opened before it. Files are searched in the reverse of the order in which they were opened; the system resource file is searched last. Because gCodeRefNum usually refers to the file containing the application’s resources, using this search path has the effect of searching through the resources that need to be in the application rather than in the document. (Document files are opened after the application file; they are therefore not included in this search.) If it does not find the resource, this routine returns NIL and the ResError function returns the result code resNotFound.
The rType parameter indicates the type of resource to be found. The rID parameter is the resource ID of the resource to be found.
MacApp calls MAGetResource from several methods that load resources specified by resource type and ID. You can use this routine in a similar fashion. For more information, see the Resource Manager chapters of Inside Macintosh, Volumes I and IV.
-- part contents for background part 5
----- text -----
Unit: UMemory
-- part contents for background part 23
----- text -----
ROUTINE
-- part contents for background part 2
----- text -----
MAGetResource
-- part contents for background part 20
----- text -----
FUNCTION MAGetResource(rType: ResType; rID: INTEGER): Handle;